/**
 * Copyright (c) 2009, 2010  Collaborative Development Group, C.S. Dept., University of Bari
 *
 * All rights reserved. This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
 * available at http://www.eclipse.org/legal/epl-v10.html
 */
package it.uniba.di.cdg.jtalk.ui.login;

import it.uniba.di.cdg.jtalk.IApplicationFacade;
import it.uniba.di.cdg.jtalk.core.LoginFailedException;

import org.osgi.service.log.LogService;

import com.google.inject.Inject;

/**
 * Login View model. 
 */
public class LoginModel implements ILoginModel {
	private final IApplicationFacade applicationFacade;
	private final LogService logger;

	/**
	 * @param applicationFacade
	 * @param logger
	 */
	@Inject
	public LoginModel( IApplicationFacade applicationFacade, LogService logger ) {
		super();
		this.applicationFacade = applicationFacade;
		this.logger = logger;
	}

	/* (non-Javadoc)
	 * @see it.uniba.di.cdg.jtalk.ui.login.ILoginModel#log(int, java.lang.String)
	 */
	@Override
	public void log( int logLevel, String message ) {
		logger.log( logLevel, message );
	}

	/* (non-Javadoc)
	 * @see it.uniba.di.cdg.jtalk.ui.login.ILoginModel#logIn(java.lang.String, java.lang.String, boolean, boolean)
	 */
	@Override
	public void logIn( String userName, String password, boolean rememberPassword, boolean automaticLogin )
			throws LoginFailedException {
		applicationFacade.logIn( userName, password, rememberPassword, automaticLogin );
	}

	/* (non-Javadoc)
	 * @see it.uniba.di.cdg.jtalk.ui.login.ILoginModel#logOff()
	 */
	@Override
	public void logOff() {
		applicationFacade.logOff();
	}
}
